//
//  RHAboutViewController.m
//  RuiHeAppApp
//
//  Created by Jun on 2023/7/20.
//

#import "RHAboutViewController.h"
#import "EnvironmentManage.h"

@interface RHAboutViewController ()

@property (nonatomic ,strong) UIView *contentView;

@end

@implementation RHAboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationItem setTitle:@"关于我们".rh_localized];
    //[self.view setBackgroundColor:CFTabViewBgColor];
    [self setupUI];
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

- (void)setupUI{
    
    UIScrollView *scroll = [[UIScrollView alloc] init];
    [self.view addSubview:scroll];
    scroll.backgroundColor = [UIColor clearColor];
    
    kWeakSelf;
    [scroll mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(weakSelf.view);
    }];
    
    _contentView = [[UIView alloc] init];
    _contentView.backgroundColor = [UIColor clearColor];
    [scroll addSubview:_contentView];
    
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(scroll);
        make.width.mas_equalTo(scroll);
        make.height.greaterThanOrEqualTo(@0.f);//此处保证容器View高度的动态变化 大于等于0.f的高度
    }];
    
    
    UIImageView *logoView = [[UIImageView alloc] init];
    logoView.contentMode = UIViewContentModeScaleAspectFit;
    [logoView setImage:[UIImage imageNamed:@"kwt_logo"]];
    logoView.backgroundColor = [UIColor whiteColor];
    [logoView.layer setCornerRadius:5];
    [_contentView addSubview:logoView];
    
    QMUILabel *nameLab = [[QMUILabel alloc] init];
    [nameLab setTextAlignment:NSTextAlignmentCenter];
    [nameLab setFont:[UIFont boldSystemFontOfSize:20]];
    [nameLab setTextColor:kCOLOR_HEX(@"3F4443")];
    [_contentView addSubview:nameLab];
    
    QMUILabel *contentLab = [[QMUILabel alloc] init];
    [contentLab setTextAlignment:NSTextAlignmentCenter];
    [contentLab setFont:[UIFont systemFontOfSize:13]];
    [contentLab setTextColor:[kCOLOR_HEX(@"3F4443") colorWithAlphaComponent:0.7]];
    [contentLab setNumberOfLines:-1];
    [_contentView addSubview:contentLab];
    
    QMUILabel *versionLab = [[QMUILabel alloc] init];
    [versionLab setTextAlignment:NSTextAlignmentCenter];
    [versionLab setFont:[UIFont boldSystemFontOfSize:13]];
    [versionLab setTextColor:kCOLOR_HEX(@"3F4443")];
    [_contentView addSubview:versionLab];
    
    
    QMUILabel *companyLab = [[QMUILabel alloc] init];
    [companyLab setTextAlignment:NSTextAlignmentCenter];
    [companyLab setFont:[UIFont boldSystemFontOfSize:13]];
    [companyLab setTextColor:kCOLOR_HEX(@"3F4443")];
    [_contentView addSubview:companyLab];
    
    [logoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_offset(80);
        make.size.mas_equalTo(CGSizeMake(100, 100));
    }];
    
    [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(200, 20));
        make.top.equalTo(logoView.mas_bottom).offset(15);
        make.centerX.equalTo(logoView);
    }];
    
    [contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(30);
        make.right.mas_offset(-30);
        make.top.equalTo(nameLab.mas_bottom).offset(20);
        make.centerX.equalTo(logoView);
        make.height.mas_equalTo(200);
    }];
    
    [versionLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-40, 20));
        make.centerX.mas_offset(0);
        make.bottom.equalTo(companyLab.mas_top).offset(-5);
    }];
    
    
    [companyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-40, 20));
        make.centerX.mas_offset(0);
        make.top.mas_offset(SCREEN_HEIGHT-kNavBarHeight-kStatusBarHeight-100);
        make.bottom.mas_offset(0);
    }];
    
    
    [nameLab setText:@"Smart Energy"];
    [contentLab setText:@"Smart Energy is committed to delivering superior products and customer experience. We work closely with clients to understand their requirements and provide tailored solutions that meet or surpass expectations. Our experienced engineers promptly address any technical questions with expertise. Over the past decade, Smart Energy has leveraged innovation and vertical integration to become a leader in smart electricity!"];
    
    NSString *version = [[[NSBundle mainBundle]infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    [versionLab setText:[NSString stringWithFormat:@"V %@",version]];
    [companyLab setText:@"© Smart Energy All Rights Reserved."];
    
    if([[EnvironmentManage sharedEnvirManage] getCurrentEnvironmentType] == TestEnvironment){
        versionLab.textColor = kCOLOR_HEX(@"#98D767");//测试环境
    }
    
    if([[EnvironmentManage sharedEnvirManage] getCurrentEnvironmentType] == DevEnvironment){
        versionLab.textColor = kCOLOR_HEX(@"#678EF2");//开发环境
    }
}


@end
